package com.itheima.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/*
    数据库：写入数据
 */
public class demo1 {
    public static void main(String[] args) throws Exception {
        // 注册驱动
        Class.forName("com.mysql.jdbc.Driver");

        // 获取连接
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/db4", "root", "root");

        // 获取语句执行对象
        Statement statement = connection.createStatement();

        // 编写SQL
        String sql = "insert into user values(null,'钱七',25)";

        // 执行SQL
        int i = statement.executeUpdate(sql);
        System.out.println(i);

        // 释放资源
        statement.close();
        connection.close();
    }
}
